﻿<Popup x:Class="BioWF.ExpressionEditor.IntellisensePopup"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:expressionEditor="clr-namespace:BioWF.ExpressionEditor"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       d:DesignHeight="200" d:DesignWidth="300"
       mc:Ignorable="d">

    <Popup.Resources>
        <expressionEditor:TypeImageConverter x:Key="TypeImageConverter" />
    </Popup.Resources>

    <ListBox x:Name="lbIntellisense"
                PreviewKeyDown="LbIntellisenseOnPreviewKeyDown"
                IsTextSearchEnabled="True" FontFamily="Segoe UI" FontSize="9pt"
                ItemsSource="{Binding}"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                ScrollViewer.VerticalScrollBarVisibility="Auto">
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <EventSetter Event="MouseDoubleClick" Handler="LbItemDoubleClick" />
            </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Margin="2" Orientation="Horizontal" ToolTip="{Binding Description}">
                    <Image Source="{Binding Type, Converter={StaticResource TypeImageConverter}}" Width="16" Height="16" Margin="2" />
                    <TextBlock x:Name="namespaceType" Text="{Binding Name}" Visibility="Collapsed"/>
                    <TextBlock x:Name="otherType">
                        <Run Text="{Binding Name, Mode=OneWay}" />
                        <Run Text=" " />
                        <Run Text="{Binding Namespace, Mode=OneWay,StringFormat='(in {0})'}" Foreground="LightGray" />
                    </TextBlock>
                </StackPanel>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding HasNamespace}" Value="false">
                        <Setter TargetName="namespaceType" Property="Visibility" Value="Visible" />
                        <Setter TargetName="otherType" Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

</Popup>
